package com.wh1200.mybatis.xmlless.model

import com.wh1200.mybatis.xmlless.annotations.Count
import com.wh1200.mybatis.xmlless.annotations.JoinTableColumn
import com.wh1200.mybatis.xmlless.enums.XmllessFieldFill
import com.wh1200.mybatis.xmlless.enums.XmllessFieldStrategy
import com.wh1200.mybatis.xmlless.model.base.BaseJoinObjectProvider
import com.wh1200.mybatis.xmlless.model.base.BaseTableFieldWrapper

/**
 *
 * @author 吴昊
 * @date 2023/12/19 16:22
 * @since v4.0.0
 * @version 1.0
 */
class XmllessTableFieldInfo(
    val fieldWrapper: BaseTableFieldWrapper,
    val joinObject: BaseJoinObjectProvider?,
    val genericType: TypeInfo
) {

  val logicDeleteValue: Any? = fieldWrapper.getLogicDelValue()
  val logicNotDeleteValue: Any? = fieldWrapper.getLogicNotDelValue()
  val property: String = fieldWrapper.getFieldName()
  val column: String = fieldWrapper.getColumn()
  val propertyType: Class<*> = fieldWrapper.getFieldType().getJavaClass()
  val isLogicDelete: Boolean = fieldWrapper.isLogicDelete()
  val isCharSequence: Boolean = fieldWrapper.isCharSequence()
  val updateStrategy: XmllessFieldStrategy = fieldWrapper.getUpdateStrategy()
  val insertStrategy: XmllessFieldStrategy = fieldWrapper.getInsertStrategy()
  val update: String? = fieldWrapper.getUpdate()
  val fieldFill: XmllessFieldFill = fieldWrapper.getFieldFillStrategy()
  val joinTableColumn: JoinTableColumn? = fieldWrapper.getJoinTableColumn()
  val count: Count? = fieldWrapper.getCount()
  val isCreatedBy: Boolean = fieldWrapper.isMarkedCreatedBy()
  val isLastModifiedBy: Boolean = fieldWrapper.isMarkedLastModifiedBy()
  val isDeletedBy = fieldWrapper.isMarkedDeletedBy()
  val isDeletedDate: Boolean = fieldWrapper.isMarkedDeletedDate()
  val isCreatedDate: Boolean = fieldWrapper.isMarkedCreatedDate()
  val isLastModifiedDate: Boolean = fieldWrapper.isMarkedLastModifiedDate()

  override fun toString(): String {
    return fieldWrapper.getFieldName()
  }

}
